#coding=utf-8
#!/usr/bin/python 
import os
import os.path

def findKeyWord(fullFileName,keyword):
	"统计文件的行数"
	totleLineCount = 0
	
	lines = []
	try:
	    f = open(fullFileName, 'rU')
	    lines = f.readlines()
	except IOError as e:
	    print e
	else:
	    for line in lines:
	        totleLineCount=totleLineCount+1
	        if line.find(keyword)!=-1:
	        	print "文件:%r  代码行:%r 内容" % (fullFileName,totleLineCount) + line
	        
	finally:
	    f.close()


rootdir = "/Users/wesleyxiao/Documents/python/ValueAddedService"

allLineCount = 0
fileNumCount = 0
for parent,dirnames,filenames in os.walk(rootdir):    #三个参数：分别返回1.父目录 2.所有文件夹名字（不含路径） 3.所有文件名字
	for filename in filenames:                        #输出文件信息
		fullFileName=os.path.join(parent,filename)
		findKeyWord(fullFileName,'红点系统')
		findKeyWord(fullFileName,"VAS_TRACE")